|
|
|
|
|
|
|
Sales_Total = IIf( Sales_Amt>500, Sales_Amt * .90, Sales_Amt) |
|
|
|
|
|
|
|
|
However, there is one thing to remember if you decide to use this function. The IIf function always evaluates both the true and false expressions, even though it will return only one of them. If evaluating the false expression results in an error, an error will occur even if the expr is true. |
|
|
|
|
|
|
|
|
The Logical Way to Do Things |
|
|
|
|
|
|
|
|
When designing your application and creating the code, you should try to keep the code's execution as logical as possible. |
|
|
|
|
|
|
|
|
Today you learned what it takes to use variables properly within your application. Many things can go wrong when you are creating an application; however, if you plan and declare your variables correctly, you will have one less thing to worry about. Complex applications will usually require many types of functions and subroutines to perform specific tasks that might be repeated at different locations in the application. |
|
|
|
|
|
|
|
|
You also learned the different ways to affect the application program flow. This will allow you to see how different sections of code executed depending on the current data being processed. This allows you to create a much more flexible application than if you had to anticipate everything that the user might do and code for each one separately. |
|
|
|
|
|
|
|
|
Q What two types of procedures can you use to perform tasks in Visual Basic? |
|
|
|
|
|
|
|
|
A Both subroutines and functions can be used to perform tasks in an application. |
|
|
|
|
|
|
|
|
Q What kind of variable has the broadest scope? |
|
|
|
|
|
|
|
|
A A variable that is declared PUBLIC has the broadest scope in an application. |
|
|
|
|
|
|
|
|
Q What are the different ways to change the flow of execution in the application? |
|
|
|
|
|
|
|
|
A There are many different ways to change the flow of a program; however, when writing the code for an application, the best ways are by using the If-Then and Select Case statements. |
|
|
|
|
|
|
|
|
Q Can a subroutine call another subroutine? |
|
|
|
|
|
|
|
|
A Yes, any subroutine or function can call any other routine in the application to which it has access, according to the routine's scope. |
|
|
|
|
|